qwen4_exp: load modelopt MIXED_PRECISION (NVFP4 experts + block-FP8 dense) checkpoints - #320
Open
gberasmus87 wants to merge 1 commit into
Open
Conversation
…ense) checkpoints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds support for loading Qwen3.8-Flash-Next checkpoints exported with modelopt
MIXED_PRECISIONquantization - NVFP4 routed experts + 128x128 block-FP8 dense (attention / GDN) weights. The common community build of this shape islovedheart/Qwen3.8-Flash-Next-NVFP4-FP8, the ~124GB quant that fits the model on a 24GB GPU via the offload backend.Before this, such a checkpoint fails to load in two places:
parse_configonly recognises a top-levelquant_algooffp8or*fp4*.MIXED_PRECISIONdeclares the per-module algo inquantized_layersinstead, soexpert_quantfell through to"none"and the offload cache tried to load the NVFP4 experts as bf16 banks ->ValueError: Missing MoE expert source layers..weight_scale_inv), butiter_weightsassumed all non-expert weights are bf16 and passed them straight to_try_fuse->RuntimeError: Promotion for Float8 Types is not supported, attempted to promote Float8_e4m3fn and BFloat16on the GDNin_projfuse.Changes
config.py: detectquant_algo == "mixed_precision", readquantized_layersto setexpert_quant = "nvfp4"(experts stay native for the offload cache), and keep every dense module bf16.weight.py:_load_maybe_block_fp8dequantizes a dense.weightto bf16 when a sibling.weight_scale_invis present (reusing the existingdequant_block_fp8kernel), and.weight_scale_invis added to_SCALE_SUFFIXESso the scale tensor is not yielded as a weight. Only block-FP8 is added - it is the only dense quant these checkpoints use.Testing
Loads and serves
lovedheart/Qwen3.8-Flash-Next-NVFP4-FP8(~124GB) on an RTX PRO 4000 Blackwell (24GB VRAM) backed by 172GB system RAM, with--moe-backend hybrid- the offload backend holds the ~124GB checkpoint resident in host RAM and streams experts to the GPU per token. Output is coherent and correct (reasoning / math / coding verified) and tool-calling works, ~22 tok/s single-stream. The new branches are gated onmixed_precision/ a present.weight_scale_inv, so no other checkpoint path changes.